﻿<?php

use yii\db\Schema;
use yii\db\Migration;

class m150505_062344_video_adspace extends Migration
{
    public function up()
    {
    	$sql = <<<FINE
DROP TABLE IF EXISTS {{%video_adspace}};
CREATE TABLE {{%video_adspace}} (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  ad_network_id int(10) NOT NULL,
  media_id int(10) NOT NULL DEFAULT '0',
  form int(1) NOT NULL DEFAULT '1' COMMENT '1 banner, 2 video',
  format_list char(20) NOT NULL COMMENT '允许广告形式集合，逗号分割，  1 static-pic, 2 dynamic-pic, 3 swf, 4 txt, 5 flv, 6 mp4',
  ad_network_adspace_id varchar(64) DEFAULT NULL,
  category_id int(11) unsigned NOT NULL COMMENT '广告位页面分类 id',
  name varchar(64) DEFAULT NULL,
  base_price varchar(32) NOT NULL COMMENT '广告位底价，按 CPM 计算',
  deal_id int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'deal id',
  in_duration int(10) unsigned NOT NULL DEFAULT '0' COMMENT '广告最小时长 s', 
  max_duration int(10) unsigned NOT NULL DEFAULT '0' COMMENT '广告最大时长 s', 
  width int(10) unsigned NOT NULL COMMENT '宽',
  height int(10) unsigned NOT NULL COMMENT '高',
  position tinyint(1) NOT NULL DEFAULT '0' COMMENT '0 未知， 1一屏，2二屏，3三屏，4其他',
  ad_form int(10) NOT NULL DEFAULT '0' COMMENT '广告投放形式 0 前贴片',
  page_url varchar(1024) NOT NULL DEFAULT '' COMMENT 'host page的url',
  code text COMMENT '广告位代码，包断位时需要填写',
  status tinyint(1) NOT NULL DEFAULT '0' COMMENT '0正常，1已暂停，2已归档',
  last_update timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (id)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
FINE;
	$this->execute($sql);
    }

    public function down()
    {
        $sql = <<<FINE
        DROP TABLE IF EXISTS {{%video_adspace}};
FINE;
		$this->execute($sql);
    }
}
